﻿/*

Functions for all around the web page

*/

// gets Garmin iFrame src
function getGarminConnectIFrameSrc() {

    $.get(
        '/Cycling/GetGarminIframeSource?id=' + $('#RoutesDropdown').val(),
        '',
        function (content) {
            $("#garminConnectIFrame").attr('src', content);
        }
    );
}

// pointPoint function
function pointPoint(id) {

    var pp = $('#' + id).pointPoint();

    $('#' + id).click(function () {
        pp.destroyPointPoint();
    });
}

// gets Flickr Set Number
function prepareGalleria(dropdownId, divId) {

    $.get(
        '/Gallery/GetGallerySet?id=' + $('#' + dropdownId).val(),       
        '',
        function (content) {

            Galleria.run('#' + divId, {
                flickr: 'set: ' + content,
                flickrOptions: {
                    sort: 'date-posted-desc',
                    thumbSize: 'small',
                    description: 'true'
                }
            });
        }
    );
}

// gets video link
function prepareVideo(dropdownId, divId) {

    $.get(
        '/Video/GetVideoLink?id=' + $('#' + dropdownId).val(),
        '',
        function (content) {
            $('#' + divId).html(content);
        }
    );
}

// prepares Google map
function initializeGoogleMap(divId) {

    var latlng = new google.maps.LatLng(46.051314, 14.509399);
    var options = {
        zoom: 11,
        center: latlng,
        mapTypeControl: true,
        streetViewControl: false,
        mapTypeId: google.maps.MapTypeId.TERRAIN
    };
    var map = new google.maps.Map(document.getElementById(divId), options);

}